package cn.neil.springcloud.gateway.simple;

import org.springframework.cloud.gateway.filter.ratelimit.KeyResolver;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import reactor.core.publisher.Mono;

@Configuration
public class RatelimitConfig {
    @Bean
    KeyResolver userKeyResolver() {
        // 根据IP来限定
        return exchange -> Mono.just( exchange.getRequest().getRemoteAddress().getHostName());
    }
}
